home *** CD-ROM | disk | FTP | other *** search
- /*
- ** Amster - Lamp
- ** Copyright © 1999-2000 by Gürer Özen
- **
- ** This program is free software; you can redistribute it and/or modify
- ** it under the terms of the GNU General Public License as published by
- ** the Free Software Foundation; either version 2 of the License, or
- ** (at your option) any later version.
- **
- ** This program is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ** GNU General Public License for more details.
- **
- ** You should have received a copy of the GNU General Public License
- ** along with this program; if not, write to the Free Software
- ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
- #include "amster.h"
-
- #include <MUI/Lamp_mcc.h>
- #include <MUI/TWFmultiLED_mcc.h>
- #include <MUI/NListview_mcc.h>
-
- struct TWFmultiLED_RGB lamp_cols[] = {
- { 0xffffffff, 0x00000000, 0x00000000 },
- { 0x00000000, 0xffffffff, 0x00000000 },
- { 0xffffffff, 0xffffffff, 0x00000000 },
- { 0x00000000, 0x00000000, 0x00000000 },
- };
-
- u_long *lamp_objs[] = { NULL, NULL, NULL, NULL };
-
- #define LAMP_RED 0
- #define LAMP_GREEN 1
- #define LAMP_YELLOW 2
- #define LAMP_BLACK 3
-
- int lamp_lamp(void);
- int lamp_twf(void);
-
-
- int lamp_create(void)
- {
- if (prf->lamps==0) {
- if(lamp_lamp()) return(1);
- if(lamp_twf()) return(1);
- }
- else {
- if(lamp_twf()) return(1);
- if(lamp_lamp()) return(1);
- }
- return(0);
- }
-
-
- void lamp_dispose(void)
- {
- int i;
-
- for (i=0; i<4; i++) {
- if(lamp_objs[i]) MUI_DisposeObject(lamp_objs[i]);
- lamp_objs[i] = NULL;
- }
- }
-
-
- int lamp_lamp(void)
- {
- int i, e=0;
-
- for (i=0; i<4; i++) {
- lamp_objs[i] = LampObject,
- MUIA_Lamp_Type, MUIV_Lamp_Type_Big,
- MUIA_Lamp_Red, lamp_cols[i].Red,
- MUIA_Lamp_Green, lamp_cols[i].Green,
- MUIA_Lamp_Blue, lamp_cols[i].Blue,
- End;
- if (!lamp_objs[i]) e++;
- }
- if (!e) return(1);
- lamp_dispose();
- return(0);
- }
-
-
- int lamp_twf(void)
- {
- int i, e=0;
-
- for (i=0;i<4;i++) {
- lamp_objs[i] = TWFmultiLEDObject,
- MUIA_TWFmultiLED_Colour, MUIV_TWFmultiLED_Colour_Custom,
- MUIA_TWFmultiLED_Custom, &lamp_cols[i],
- End;
- if (!lamp_objs[i]) e++;
- }
- if (!e) return(1);
- lamp_dispose();
- return(0);
- }
-
-
- void lamp_useinlist(u_long *list)
- {
- if (!lamp_objs[LAMP_RED]) return;
- DoMethod(list, MUIM_NList_UseImage, lamp_objs[LAMP_BLACK ], 1, 0);
- DoMethod(list, MUIM_NList_UseImage, lamp_objs[LAMP_RED ], 2, 0);
- DoMethod(list, MUIM_NList_UseImage, lamp_objs[LAMP_YELLOW], 3, 0);
- DoMethod(list, MUIM_NList_UseImage, lamp_objs[LAMP_GREEN ], 4, 0);
- }
-
-
- char *lamp_getforlist(int i)
- {
- static char *objs[] = {
- "\33c\33o[1]",
- "\33c\33o[2]",
- "\33c\33o[3]",
- "\33c\33o[4]",
- "\33c?",
- "\33c!",
- "\33c!!",
- "\33c!!!"
- };
-
- if (lamp_objs[LAMP_RED]) return(objs[i]);
- return(objs[i+4]);
- }
-